package com.mpm.ai.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

import java.util.function.Function;

@Configuration
public class OrderTools {

	@Autowired
	OrderService orderService;

	public record CancelOrderRequest(String orderNumber) {

	}

	@Bean
	@Description("取消订单")
	public Function<CancelOrderRequest, String> cancelOrder() {
		return request -> {
			orderService.cancelOrder(request.orderNumber);
			return "";
		};
	}

	public record CreateOrderRequest(String goodsCode, Integer num) {

	}

	@Bean
	@Description("新增订单")
	public Function<CreateOrderRequest, String> createOrder() {
		return request -> {
			orderService.createOrder(request.goodsCode, request.num);
			return "";
		};
	}

}
